<?php 
use yii\helpers\Html;
use yii\widgets\ActiveForm;

?>

<h1>实习登录和注册表单
</h1>
<div class="main-agileits">
<!--form-stars-here-->
		<div class="form-w3-agile">
			<h2 class="sub-agileits-w3layouts">登录</h2>
			<?php $form = ActiveForm::begin(); ?>
					<input id="email" type="email" name="User[email]"  placeholder="邮箱" required="">
					<input id='pwd' type="password" name="User[password]" required=""  placeholder="密码">
					<a href="#" class="forgot-w3layouts">忘记密码 ?</a>
				<div class="submit-w3l">
					<input id="login" type="button" value="登录">
				</div>
				<p class="p-bottom-w3ls"><a href="http://www.job.com/frontend/web/index.php?w=login%2Fregister">点击注册</a>如果你没有一个帐户。
.</p>
			<?php ActiveForm::end(); ?>
		</div>
		</div>

<script>
	$(function(){
		$('#login').click(function(){
			var csrf = $("input[name='_csrf']").val();
			var email = $('#email').val()
			var pwd = $('#pwd').val()
			if(email != '' && pwd != ''){
				$.ajax({
					type:"post",
					url:"index.php?w=login/login_do",
					data:{
						'email':email,
						'_csrf':csrf,
						'password':pwd
					},
					dataType:"json",
					success:function(data) {
						if(data.error){
							location.href = 'index.php?w=home/index';
						}else{
							alert(data.msg)
						}
					}
				})
			}
		})
	})
</script>